package com.athena.crm.utils;

import com.athena.common.utils.redis.RedisUtils;
import com.athena.crm.constant.CommonConstant;

/**
 * SerialNumberUtil
 *
 * @author ZHANGHAN
 * @date 2023/6/21 10:32
 */
public class SerialNumberUtil {

    public static String getUnlockSerialNumber() {
        Long currentValue = RedisUtils.getAtomicValue(CommonConstant.UNLOCK_SERIAL_NUMBER_KEY);
        if (currentValue == null) {
            RedisUtils.setAtomicValue(CommonConstant.UNLOCK_SERIAL_NUMBER_KEY, 0);
            currentValue = RedisUtils.getAtomicValue(CommonConstant.UNLOCK_SERIAL_NUMBER_KEY);
        }
        String currentValueStr = String.format("%07d", currentValue);
        String resultValue = "NO".concat(currentValueStr);
        return resultValue;
    }
}
